<template>
  <div class="my">
    <div class="content">
      <div class="background">
        <div class="header">
          <div class="avatar">
            <img src="../assets/Q3.png" alt="" v-if="!userinfo.length > 0" />
            <img src="../assets/avatar.jpg" alt="" v-else />
          </div>
          <p @click="$router.push('/login')" v-if="!userinfo.length > 0">
            点击登录
          </p>
          <p v-else>{{ userinfo[0].userName }}</p>
        </div>
        <div class="info">
          <div>
            <span>0</span>
            <p>视频</p>
          </div>
          <div @click="toFollow()">
            <span v-if="!userinfo.length > 0">0</span>
            <span v-else>{{ followList.length }}</span>
            <p>关注</p>
          </div>
          <div>
            <span>0</span>
            <p>粉丝</p>
          </div>
        </div>
      </div>
      <div class="set">
        <div class="list">
          <h3>创作人中心</h3>
          <ul>
            <li>
              <span class="iconfont icon-neirongguanli1"></span>
              <p>内容管理</p>
            </li>
            <li>
              <span class="iconfont icon-chuanshuliebiao"></span>

              <p>传输列表</p>
            </li>
            <li>
              <span class="iconfont icon-zuoye"></span>

              <p>作品通</p>
            </li>
            <li>
              <span class="iconfont icon-shenfenrenzheng"></span>

              <p>身份认证</p>
            </li>
          </ul>
        </div>
        <div class="list">
          <h3>社区服务</h3>
          <ul>
            <li>
              <span class="iconfont icon-wodekecheng"></span>

              <p>我的课程</p>
            </li>
            <li>
              <span class="iconfont icon-yigou"></span>

              <p>已购素材</p>
            </li>
            <li>
              <span class="iconfont icon-dingdanguanli1"></span>

              <p>订单管理</p>
            </li>
            <li>
              <span class="iconfont icon-a-ziyuan688"></span>
              <p>会员中心</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const userinfo = ref([]);
const followList = ref(JSON.parse(localStorage.getItem("followList")) || []);

function getUser() {
  if (JSON.parse(localStorage.getItem("userinfo"))) {
    userinfo.value = (JSON.parse(localStorage.getItem("userinfo")));
    console.log(userinfo.value);
  } else {
    userinfo.value = [];
    console.log(userinfo.value.length);
  }
  // console.log(userinfo.value.length);
}
getUser();
function toFollow() {
  router.push("/follow");
}
</script>

<style lang="scss" scoped>
.my {
  .content {
    
    .background {
      background-image: linear-gradient(#f6cbc5, #f5f5f5);
    }
    background-color: #f5f5f5;
    // padding: 0rem 12rem;
    height: 100vh;
    .header {
      padding:40rem 20rem 0rem;
      display: flex;
      align-items: center;
      .avatar {
        img {
          width: 50rem;
          height: 50rem;
          border-radius: 50%;
          margin-right: 15rem;
        }
      }
      p {
        font-size: 18rem;
        color: #000;
        font-weight: bold;
      }
    }
    .info {
      display: flex;
      justify-content: space-around;
      margin: 25rem 0;
      div {
        display: flex;
        flex-direction: column;
        align-items: center;
        span {
          color: #000;
        }
        P {
          color: #666;
        }
      }
    }
    .set {
      padding: 0rem 12rem;
    }
    .list {
      padding: 25rem 15rem;
      background-color: #fff;
      margin-bottom: 25rem;
      border-radius: 10rem;
      h3 {
        font-size: 16rem;
        color: #000;
        font-weight: bold;
        margin-bottom: 35rem;
      }
      ul {
        display: flex;
        justify-content: space-between;
        li {
          display: flex;
          flex-direction: column;
          align-items: center;
          span {
            font-size: 18rem;
            color: #666;
          }
          p {
            font-size: 14rem;
            margin-top: 20rem;
          }
        }
      }
    }
  }
}
</style>